﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WRJ
{
	public partial class ManageAdmin : BaseDBUserControl
	{
		private Button ScoreButton;
		string[] title = { "系统编号", "管理员用户名", "管理员密码", "备注" };

		public ManageAdmin(MainMenuDB menu, Button button)
		{
			InitializeComponent();
			ScoreButton = button;
			ScoreButton.Enabled = false;

			menu.Text = "管理员模式 —— 管理员管理";

			dataGridView1.DataSource = databaseWRJDataSet1.AdminInfo;
			for (int i = 0; i < title.Length; i++)
			{
				dataGridView1.Columns[i].HeaderText = title[i];
				dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
			}

			adminInfoTableAdapter1.Fill(databaseWRJDataSet1.AdminInfo);
			
			AcceptButton.Click +=new EventHandler(AcceptButton_Click);
		}

		void ScoreButton_Click(object sender, EventArgs e)
		{

		}

		void AcceptButton_Click(object sender, EventArgs e)
		{
			try
			{
				adminInfoTableAdapter1.Update(databaseWRJDataSet1.AdminInfo);
				MessageBox.Show("数据提交成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}

		}
	}
}
